package Java.BlackHorse.doudizu1;

import java.util.ArrayList;
import java.util.Collections;

public class PokerGame {
    /*
    完成控制台的三步：
    1. 准备牌
    2. 洗牌
    3. 发牌
    4. 看牌
     */

    //牌盒 准备牌
    static ArrayList<String> list = new ArrayList<>();

    static {
        String[] color = {"♣", "♠","♥","♦"};
        String[] number = {"3","4","5","6","7","8","9","10","J","Q","K","A","2"};

        for(String c : color){
            for(String n : number){
               list.add(c+n);
            }
        }
        list.add("Joker");
        list.add("joker");

//        System.out.println(list);
    }

    //洗牌
    public PokerGame(){

        Collections.shuffle(list);
//        System.out.println(list);

    //发牌
    ArrayList<String> player1 = new ArrayList<>();
    ArrayList<String> player2 = new ArrayList<>();
    ArrayList<String> player3 = new ArrayList<>();
    ArrayList<String> lord = new ArrayList<>();
    for(int i = 0; i < list.size();i++){
        //底牌
        if(i<=2) {
            lord.add(list.get(i));
            continue;
        }
        //给玩家发牌
        if(i%3==0){
            player1.add(list.get(i));
        }else{
            if(i%3==1){
                player2.add(list.get(i));
            }else{
                player3.add(list.get(i));
            }
        }
    }
        lookPoker("二狗",player1);
        lookPoker("富贵",player2);
        lookPoker("麻子",player3);
        lookPoker("底牌",lord);
    }
    //看牌
    public void lookPoker(String name,ArrayList<String> list){
        System.out.println(name+"：");
        for(String poker : list){
            System.out.print(poker+" ");
        }
        System.out.println();
    }
}
